define([
	'jquery',
	'underscore',
	'backbone',
	'moment',

	'baseView',
	'text!forum/thread/thread_page.html',
	'js/myUtil.js'
], function($, _, Backbone, moment, BaseView, tpl, myUtil) {
	return BaseView.extend({

		render: function(cb) {
			var that = this;
			myUtil.getThreadByPage(1, function(err, data) {
				console.log('page date', data);
				that.threadsData = data;

				var tmpl = _.template(tpl);
				var tmpl2 = tmpl({
					threads: data.result
				})
				$(that.el).html(tmpl2);
				if (!$(this.el).is(":visible")) // if hide then show
					that.show();
				cb && cb();
			});
		},

		events: {
			"click #toPostThread": "toPostThread"
		},

		toPostThread: function(event) {
			window.location.href = "#forum/thread/thread_post.js";
		}
	});
});